#include "PhotoPlayerUi.h"
#include "ui_PhotoPlayerUi.h"
#include "WidgetHandler.h"
#include "BootSetting.h"
#include "MiscData.h"
#include "LogoUtility.h"
#include "Mcu.h"

#include <AuthorityDialog.h>
#include <Mpp.h>

PhotoPlayerUi::PhotoPlayerUi(QWidget *parent) :
    BaseWidget(parent),
    ui(new Ui::PhotoPlayerUi)
{
    ui->setupUi(this);
    ui->left->setVisible(false);
    ui->right->setVisible(false);
    LogoUtility::getInstance()->addLogoLabel(ui->logo);
}

PhotoPlayerUi::~PhotoPlayerUi()
{
    delete ui;
}

void PhotoPlayerUi::activate() {
    #ifdef arm
        Mpp::getInstance()->stopRealtimeImage();
    #endif
    QPixmap image;
    QString path = RuntimeData::MiscData::getInstance()->g_miscDataInfo.currentImagePath;
    image.load(path);
    ui->photo->setPixmap(image);
}

void PhotoPlayerUi::inactivate()
{

}

void PhotoPlayerUi::changeEvent(QEvent *e)
{
    QWidget::changeEvent(e);
    switch (e->type()) {
    case QEvent::LanguageChange:
        ui->retranslateUi(this);
        break;

    default:
        break;
    }
}
void PhotoPlayerUi::on_gohome_clicked()
{
    Mcu::getInstance()->touchSoundBeepMessage();
    WidgetHandler::getInstance()->displayWidget(HomeUi_Id);
}

void PhotoPlayerUi::on_goback_clicked()
{
    Mcu::getInstance()->touchSoundBeepMessage();
    WidgetHandler::getInstance()->displayWidget(PatientInfoUi_Id);
}

void PhotoPlayerUi::on_pushButton_clicked() {
    Mcu::getInstance()->touchSoundBeepMessage();
    int userId = RuntimeData::BootSetting::getInstance()->g_bootSettingInfo.currentUserId;

    if (userId < 0) {
        AuthorityDialog::getInstance()->setParent(this);
        AuthorityDialog::getInstance()->setAuthorityType(AuthorityType_Null);
        AuthorityDialog::getInstance()->exec();
        return;
    } else {
        QFile(RuntimeData::MiscData::getInstance()->g_miscDataInfo.currentImagePath).remove();
        WidgetHandler::getInstance()->displayWidget(PatientInfoUi_Id);
    }
}

///<加
void PhotoPlayerUi::on_right_clicked() {

}
///<减
void PhotoPlayerUi::on_left_clicked() {

}
